package com.taptech.doufu.ui.view.weex;

import android.view.MotionEvent;
import android.view.View;

import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.ui.action.BasicComponentData;
import com.taobao.weex.ui.component.WXDiv;
import com.taobao.weex.ui.component.WXVContainer;
import com.taobao.weex.utils.WXUtils;

/**
 * Created by qlx on 2016/12/8.
 */

public class QLXDivComponent extends WXDiv {


    public QLXDivComponent(WXSDKInstance instance, WXVContainer parent, BasicComponentData basicComponentData) {
        super(instance, parent, basicComponentData);
    }

    @Override
    protected boolean setProperty(String key, Object param) {
        switch (key) {
            case "clip":
            {

                if (getHostView() != null){
                    Boolean value = WXUtils.getBoolean(param,true);
                    getHostView().setClipChildren(value);
                }
                return true;
            }
            case "interaction":
            {
                if (getHostView() != null){
                    Boolean enable = WXUtils.getBoolean(param,true);
                    getHostView().setClickable(enable);
                    getHostView().setOnTouchListener(new View.OnTouchListener() {
                        @Override
                        public boolean onTouch(View v, MotionEvent event) {
                            return v.isClickable();
                        }
                    });

                }
                return true;
            }
        }
        return super.setProperty(key, param);
    }


}
